package com.salim.leetcode.$119;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class PascalsTriangleII {
    public List<Integer> getRow(int rowIndex) {
        Integer[] array = new Integer[rowIndex+1];
        array[0] = 1;
        for(int i=0;i<rowIndex;i++){
            int j=rowIndex;
            while (j>0){
                if(array[j]==null){
                    array[j] = 0;
                }
                if(array[j-1]==null){
                    array[j-1] = 0;
                }
                array[j] = array[j]+array[j-1];
                j--;
            }
        }
        return Arrays.asList(array);
    }
}
